import { createApp } from "vue";
import App from "./App.vue";
import { router } from "./router"
import { Icon, Tabbar, TabbarItem, Image, Form, Field, CellGroup, Button, Uploader, Toast, Grid, GridItem, Dialog, Popover, Search, List, Cell, Cascader, Badge, Picker, Popup, Swipe, SwipeItem, FloatingPanel, Tab, Tabs, Progress, PullRefresh, Tag, Checkbox, CheckboxGroup, Radio, RadioGroup, Loading } from "vant";
import { createPinia } from "pinia";
import '@vant/touch-emulator';
import "@xterm/xterm/css/xterm.css"
import 'vant/lib/index.css';
import './assets/global.scss'; // 导入全局样式

import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'

import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);

const app = createApp(App);
app.use(router);
app.use(pinia);

app.use(Tabbar); app.use(Cascader);
app.use(TabbarItem);
app.use(Icon);
app.use(Image);
app.use(Field);
app.use(CellGroup);
app.use(Button);
app.use(Form);
app.use(Uploader);
app.use(Toast);
app.use(Grid);
app.use(GridItem);
app.use(Dialog);
app.use(Popover);
app.use(Search);
app.use(List);
app.use(Cell);
app.use(Badge);
app.use(Picker);
app.use(Popup);
app.use(Swipe);
app.use(SwipeItem);
app.use(FloatingPanel);
app.use(Tab);
app.use(Tabs);
app.use(Progress);
app.use(PullRefresh);
app.use(Tag);
app.use(Checkbox);
app.use(CheckboxGroup);
app.use(Radio);
app.use(RadioGroup);
app.use(Loading);
app.mount("#app");

// @ts-ignore: worker
self.MonacoEnvironment = {
    getWorker(_: string, label: string) {
        if (label === 'json') {
            return new jsonWorker()
        }
        if (['css', 'scss', 'less'].includes(label)) {
            return new cssWorker()
        }
        if (['html', 'handlebars', 'razor'].includes(label)) {
            return new htmlWorker()
        }
        if (['typescript', 'javascript'].includes(label)) {
            return new tsWorker()
        }
        return new EditorWorker()
    }
}